package com.dhcc.bpm.modules.scf.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dhcc.bpm.modules.scf.dto.ScfPaymentInfoDTO;
import com.dhcc.bpm.modules.scf.entity.ScfPaymentInfo;
import com.dhcc.bpm.modules.scf.vo.ScfPaymentInfoVO.ScfGetPaymentDetailsVO;
import com.dhcc.bpm.modules.scf.vo.ScfPaymentInfoVO.ScfGetPaymentListVO;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

/**
 * 支付信息-Mapper接口
 */
@Repository
public interface ScfPaymentInfoMapper extends BaseMapper<ScfPaymentInfo> {
    /**
     * 自定义分页查询
     */
    List<ScfGetPaymentListVO> selectScfPaymentInfoPage(IPage<ScfGetPaymentListVO> page, ScfPaymentInfoDTO scfPaymentInfo);

    /**
     * 支付信息详情查看
     */
    ScfGetPaymentDetailsVO getDetail(String rowId);

    /**
     * 查询传入的支付回单号是否存在
     */
    String isWithInvoice(String paymentNum);

    /**
     * 传入支付回单号查询支付rowId
     */
    String selectRowIdBypaymentNum(String paymentNum);


    /**
     * 根据支付回单号更新支付回单的剩余金额及使用状态
     *
     * @param paymentNum
     * @param useSts
     * @return
     */
    int updateRemainAmountAndSseStsZSRK_REMAIN_AMOUNT(String paymentNum, BigDecimal zsrkRemainAmount, String useSts);

    int updateRemainAmountAndSseStsLfrkRemainAmount(String paymentNum, BigDecimal lfrkRemainAmount, String useSts);
    /**
     * 根据支付回单号码获取该回单的当前剩余金额
     *
     * @param paymentNum
     * @return
     */
    BigDecimal selectZsrkRemainAmountByPaymentNum(String paymentNum);

    BigDecimal selectLfrkRemainAmountByPaymentNum(String paymentNum);

    /**
     * 根据支付回单号码获取该回单的总面值
     *
     * @param paymentNum
     * @return
     */
    BigDecimal selectAmountByPaymentNum(String paymentNum);

    /**
     * 根据支付回单号查询对应关联的再生入库单单号
     *
     * @param paymentNum
     * @return
     */
    List<String> getRenewableInByPaymentNum(String paymentNum);

    /**
     * 根据支付回单号查询对应关联的利废入库单单号
     *
     * @param paymentNum
     * @return
     */
    List<String> getRecyclingInByPaymentNum(String paymentNum);

    /**
     * 根据支付单号查询与利废入库关联关系表中该支付回单一共被使用过多少金额
     *
     * @param paymentNum
     * @return
     */
    BigDecimal getRecyclingUseAmountByPaymentNum(String paymentNum);

    /**
     * 根据支付单号查询与再生入库关联关系表中该支付回单一共被使用过多少金额
     *
     * @param paymentNum
     * @return
     */
    BigDecimal getRenewableUseAmountByPaymentNum(String paymentNum);

    boolean deleteByIds(String[] ids);


    List<ScfGetPaymentListVO> queryScfGetPaymentListVOByInvoiceRowId( String invoiceRowId);


    void updateRemainAmountWs();

    void updateRemainAmountZsrk();

    void updateRemainAmountLfrk();

    void updateRemainAmountbyPaymentNumWs( );
    void updateRemainAmountbyPaymentNumLfrk( );
    void updateRemainAmountbyPaymentNumZsrk();

    void initSueSts();

}
